#include <iostream>
using namespace std;
const int N = 10;
int a[N] = {1, 2, 3, 4, 5, 5, 5, 6, 7, 8};
void search_2(int *a, int t, int &bg, int &ed)
{
    int l = 0, r = N - 1;
    while (l < r)
    {
        int mid = (l + r) / 2;
        if (a[mid] < t)
        {
            l = mid + 1;
        }
        else
        {
            r = mid;
        }
    }
    // 没有该元素
    if (a[l] != t)
    {
        return;
    }
    bg = l;
    r = N - 1;
    while (l < r)
    {
        int mid = (l + r + 1) / 2;
        if (a[mid] > t)
        {
            
            r = mid - 1;
        }
        else
        {
            l = mid;
        }
    }
    ed = r;
}
int main()
{
    int l = 0, r = 0;
    search_2(a, 5, l, r);
    cout << l << " " << r;

    return 0;
}